/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.BehaviorStateMachines;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.*;
import edu.pku.sei.modeler.model.core.*;
import edu.pku.sei.modeler.model.xml.XMLUtility;

import edu.pku.sei.modeler.model.uml.Kernel.Classifier;
import edu.pku.sei.modeler.model.uml.Kernel.RedefinableElement;

import edu.pku.sei.modeler.model.uml.Kernel.Namespace;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;

/**
 * @generated
 *
 */
public class Region extends Namespace implements IRegion {
	// attributes
	
	
	
	protected boolean isLeaf;
	
	
	// references
	
	protected MetaTypedList transition;
	
	protected MetaTypedList subvertex;
	
	protected MetaTypedList extendedRegion;
	
	
	
	protected MetaTypedList redefinitionContext;
	
	protected MetaTypedList redefinedElement;
	
	// getters & setters for attributes
	
	@MethodProperty(
			id = "REGION_ISLEAF",
			catalog = "Model",
			name = ModelPackage.REDEFINABLEELEMENT_ISLEAF,
			setter = "setisLeaf"
			)
	
	public boolean getIsLeaf() {
		return isLeaf;
	}
	public void setIsLeaf(boolean newIsLeaf) {
		boolean oldisLeaf = isLeaf;
		isLeaf = newIsLeaf;
		firePropertyChange(ModelPackage.REDEFINABLEELEMENT_ISLEAF, oldisLeaf, newIsLeaf);
	}
	
	// getters for references
	
	public MetaTypedList getTransition() {
		if(transition == null) {
			transition = new MetaTypedList(Transition.class, this, ModelPackage.REGION_TRANSITION);
		}
		return transition;
	}
	
	public MetaTypedList getSubvertex() {
		if(subvertex == null) {
			subvertex = new MetaTypedList(Vertex.class, this, ModelPackage.REGION_SUBVERTEX);
		}
		return subvertex;
	}
	
	public MetaTypedList getExtendedRegion() {
		if(extendedRegion == null) {
			extendedRegion = new MetaTypedList(Region.class, this, ModelPackage.REGION_EXTENDEDREGION);
		}
		return extendedRegion;
	}
	
	public MetaTypedList getRedefinitionContext() {
		if(redefinitionContext == null) {
			redefinitionContext = new MetaTypedList(Classifier.class, this, ModelPackage.REDEFINABLEELEMENT_REDEFINITIONCONTEXT);
		}
		return redefinitionContext;
	}
	
	public MetaTypedList getRedefinedElement() {
		if(redefinedElement == null) {
			redefinedElement = new MetaTypedList(RedefinableElement.class, this, ModelPackage.REDEFINABLEELEMENT_REDEFINEDELEMENT);
		}
		return redefinedElement;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.REDEFINABLEELEMENT_ISLEAF, isLeaf);
		
		// references
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.REGION_TRANSITION, transition);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.REGION_SUBVERTEX, subvertex);
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.REGION_EXTENDEDREGION, extendedRegion);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.REDEFINABLEELEMENT_REDEFINITIONCONTEXT, redefinitionContext);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.REDEFINABLEELEMENT_REDEFINEDELEMENT, redefinedElement);		
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		isLeaf = XMLUtility.xmlInstance.deSerializeBoolean(root, ModelPackage.REDEFINABLEELEMENT_ISLEAF);
		
		// references
		
		this.getTransition().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.REGION_TRANSITION));
		
		this.getSubvertex().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.REGION_SUBVERTEX));
		
		this.getExtendedRegion().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.REGION_EXTENDEDREGION, this));
		
		this.getRedefinitionContext().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.REDEFINABLEELEMENT_REDEFINITIONCONTEXT, this));
		
		this.getRedefinedElement().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.REDEFINABLEELEMENT_REDEFINEDELEMENT, this));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		// references
		
		else if(ModelPackage.REGION_EXTENDEDREGION.equals(featureID)) {
			getExtendedRegion().add(value);
		}
		
		else if(ModelPackage.REDEFINABLEELEMENT_REDEFINITIONCONTEXT.equals(featureID)) {
			getRedefinitionContext().add(value);
		}
		
		else if(ModelPackage.REDEFINABLEELEMENT_REDEFINEDELEMENT.equals(featureID)) {
			getRedefinedElement().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 